Ever had an error like:
$ ./my-perl-script
Can't locate ... in @INC (@INC contains: ...) at ... line ... .
BEGIN failed--compilation aborted at ... line ... .
|
|
Well, this often happens when you have a directory
with your perl scripts and its own modules, which
you have not installed yet.
A good solution is usually to go in the lib/ directory
of the tarball, or the directory containing the name
of the missing module. For example, if the message above
complains about missing RBC/XML.pm, with something like:
Can't locate RBC/XML.pm in @INC (@INC ...
|
|
You can simply:
$ find . -type d -name 'RBC'
./lib/RBC
$ cd lib
$ ../my-perl-script
|
|
Well, if you can't change directory, or you get another
error about another missing library, you can simply
use the PERL5LIB or PERLLIB environment variable, with
something like:
$ PERL5LIB=/home/.../lib/ ./my-perl-script
or
$ export PERL5LIB=/home/.../lib/
$ ./my-perl-script
|
|
Note that if you use an absolute path in PERL5LIB, you can
run my-perl-script from anywhere on your file system. Instead
of PERL5LIB you can always use PERLLIB, or the -I parameter
to the perl executable, with something like:
$ perl -I/home/.../lib/ ./my-perl-script
|
|
PERLLIB and PERL5LIB are ignored in case the script is
somewhat privileged. To know more about all of this, just
run:
and search '-I' or 'PERL5LIB'.